package com.dkm.biz.gl.repository.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.gl.domain.EavValueVarchar;
import com.dkm.biz.gl.persistence.dao.EavValueVarcharDao;
import com.dkm.biz.gl.persistence.dao.EavValueVarcharQueryDao;
import com.dkm.biz.gl.persistence.entity.EavValueVarcharPo;
import com.dkm.biz.gl.repository.EavValueVarcharRepository;
import com.dkm.biz.repository.AbstractRepository;

/**
 * 对象功能:属性值字符串 Repository接口的实现类
 * 开发公司:SKG.COM
 * 开发人员:Yuki
 * 创建时间:2014-12-19 10:22:05
 */
@Repository
public class EavValueVarcharRepositoryImpl extends AbstractRepository<String, EavValueVarcharPo,EavValueVarchar> implements EavValueVarcharRepository{
	  
	@Resource
	private  EavValueVarcharQueryDao eavValueVarcharQueryDao;
	
	@Resource
	private EavValueVarcharDao eavValueVarcharDao;

	public EavValueVarchar newInstance() {
		EavValueVarcharPo po = new EavValueVarcharPo();
		EavValueVarchar eavValueVarchar = SpringHelper.getBean(EavValueVarchar.class);
		eavValueVarchar.setData(po);
		return eavValueVarchar;
	}

	public EavValueVarchar newInstance(EavValueVarcharPo po) {
		EavValueVarchar eavValueVarchar = SpringHelper.getBean(EavValueVarchar.class);
		eavValueVarchar.setData(po);
		return eavValueVarchar;
	} 
	
	@Override
	protected IQueryDao<String, EavValueVarcharPo> getQueryDao() {
		return eavValueVarcharQueryDao;
	}
	public EavValueVarcharPo findByProdAttr(String entityId, String attrId){
		 Map<String,Object> params=new HashMap<String,Object>();
			params.put("entityId",entityId);
			params.put("attrId", attrId);
			return eavValueVarcharQueryDao.getByKey("findByProdAttr", params);
	}
	@Override
	public List<EavValueVarcharPo> findAllByEntityId(String entityId) {
		Map<String,Object> params=new HashMap<String,Object>();
		params.put("whereSql"," entity_id_='"+entityId+"'");
		return  eavValueVarcharQueryDao.findAll(params);
	}

	@Override
	public void update(String entityId, String attrKey, String attrValue) {
		eavValueVarcharDao.updateByEntityIdAndKey(entityId, attrKey, attrValue);
		
	}
	
	
}
